<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta name="author" content="中文Lee 360811363@qq.com">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
    <!--
    * [LupMisNotAllowedSync]
    * 本代码为系统自动生成代码，请根据自己业务进行修改;
    * 生成时间 2022-02-15 18:29:17;
    * 版权所有 2020-2022 lizhongwen，并保留所有权利;
    * 说明: 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；不允许对程序代码以任何形式任何目的的再发布;
    * 作者: 中文Lee;
    * 作者主页: http://www.lizhongwen.com;
    * 邮箱: 360811363@qq.com;
    * QQ: 360811363;
    -->
    <style>
        .code .layui-form-checkbox {
            width: 135px !important;
        }
        
        .page .layui-form-checkbox {
            width: 110px !important;
        }
    </style>
</head>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">

            <form class="layui-form" action="">
                <input type="hidden" name="actions" value="">

                <input type="hidden" name="table_name" value="">
                <input type="hidden" name="pages" lay-verify="required" lay-reqtext="请至少选择一个要同步的功能" value="Controller.php,Service.php,ServiceImpl.php,Mapper.php,Mapper.xml,index.html,add.html,edit.html">

                <fieldset class="layui-elem-field">
                    <legend>生成代码</legend>
                    <div class="layui-field-box">
                        <div class="layui-form-item code" style="line-height: 50px;">
                            <input type="checkbox" lay-filter="btn" value="Controller.php" checked title="Controller.php" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="Service.php" checked title="Service.php" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="ServiceImpl.php" checked title="ServiceImpl.php" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="Mapper.php" checked title="Mapper.php" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="Mapper.xml" checked title="Mapper.xml" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="index.html" checked title="index.html" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="add.html" checked title="add.html" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                            <input type="checkbox" lay-filter="btn" value="edit.html" checked title="edit.html" autocomplete="off" class="layui-input pageCode" lay-skin="primary">
                        </div>
                    </div>
                </fieldset>


                <fieldset class="layui-elem-field">
                    <legend>初始化页面以及操作功能</legend>
                    <div class="layui-field-box page" style="line-height: 50px;">
                        <input type="checkbox" lay-filter="initPage" value="lists" title="页面接口" autocomplete="off" class="layui-input pageBtn" lay-skin="primary">
                        <input type="checkbox" lay-filter="initAction" disabled value="add" title="添加" autocomplete="off" class="layui-input actionBtn" lay-skin="primary">
                        <input type="checkbox" lay-filter="initAction" disabled value="del" title="删除" autocomplete="off" class="layui-input actionBtn" lay-skin="primary">
                        <!-- <input type="checkbox" lay-filter="initAction" disabled value="delAll" title="批量删除" autocomplete="off" class="layui-input actionBtn" lay-skin="primary"> -->
                        <input type="checkbox" lay-filter="initAction" disabled value="edit" title="编辑" autocomplete="off" class="layui-input actionBtn" lay-skin="primary">
                    </div>
                </fieldset>


                <div class="layui-form-item" style="text-align:center;">
                    <button class="layui-btn" lay-submit="" lay-filter="form-submit">立即提交</button>
                </div>
            </form>



        </div>
    </div>

    <script src="../../../js/run.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <script type="text/javascript">
        $init(function() {
            form.on('checkbox(btn)', function(data) {
                var btnArr = [];
                var i = 0;
                $(".pageCode").each(function(index, obj) {
                    if ($(this).is(':checked')) {
                        btnArr[i] = $(this).val();
                        i++;
                    }
                });
                $("input[name='pages']").val(btnArr);
            });
            var btnArr = [];
            form.on('checkbox(initPage)', function(data) {
                if ($(this).is(':checked')) {
                    $(".actionBtn").removeAttr("disabled");
                    $(".layui-checkbox-disbaled").removeClass("layui-checkbox-disbaled");
                    $(".layui-checkbox-disbaled").removeClass("layui-disabled");
                    layui.form.render(null, null);
                    btnArr[0] = "lists";
                } else {
                    $(".actionBtn").each(function(index, obj) {
                        $(this).attr("checked", false);
                        $(this).attr("disabled", true);
                        layui.form.render(null, null);
                        btnArr = [];
                    });
                }
                var _bth = [];
                var jj = 0;
                for (var j = 0; j < btnArr.length; j++) {
                    if (btnArr[j] != "") {
                        _bth[jj] = btnArr[j];
                        jj++;
                    }
                }
                $("input[name='actions']").val(_bth);
            });

            form.on('checkbox(initAction)', function(data) {
                var i = 1;
                $(".actionBtn").each(function(index, obj) {
                    if ($(this).is(':checked')) {
                        btnArr[i] = $(this).val();
                    } else {
                        btnArr[i] = "";
                    }
                    i++;
                });
                var _bth = [];
                var jj = 0;
                for (var j = 0; j < btnArr.length; j++) {
                    if (btnArr[j] != "") {
                        _bth[jj] = btnArr[j];
                        jj++;
                    }
                }
                $("input[name='actions']").val(_bth);
            });
            var tableName = getQueryString("table_name");
            $("input[name='table_name']").val(tableName);
            frameSubmitSelf(base_gateway + "sys/field/syncCode", true, function(ret) {


            });
        });

        function frameSubmitSelf(url, isReloadTableList = true, callback = false, dataJson = false) {
            var index = parent.layer.getFrameIndex(window.name);
            //监听提交
            layui.form.on('submit(form-submit)', function(data) {
                var btn = layui.jquery(this);
                if (btn.hasClass("layui-btn-disabled")) {
                    layer.msg('数据传输中，请勿重复提交...', {
                        shade: [0.1, '#393D49'],
                        time: 2000
                    });
                    return false;
                }
                btn.addClass('layui-btn-disabled');
                var loading = layer.load(2, {
                    shade: [0.1, '#393D49'],
                });
                layer.msg('正在提交数据...', {
                    shade: [0.1, '#393D49'],
                    time: 2000
                });

                request(url, data.field, function(ret) {
                    var code = ret.code;
                    layer.close(loading);
                    layer.closeAll('loading');
                    setTimeout(function() {
                        btn.removeClass('layui-btn-disabled');
                    }, 1500);
                    if (code == 200) {
                        if (callback) {
                            callback(ret);
                        }
                        var data = ret.data;
                        var str = "";
                        for (var i = 0; i < data.length; i++) {
                            str += data[i] + "<br>";
                        }
                        layer.alert(str, function(index1) {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        });
                    } else {
                        layer.msg("同步失败!");
                    }
                });
                return false;
            });
        }
    </script>
</body>

</html>